package main

import "fmt"

func sum(s []int, ch chan int) {
	sum := 0
	for _, v := range s {
		sum += v
	}
	ch <- sum
}

func main() {
	arr := []int{4, 1, 3, -9, 4, 2}
	ch := make(chan int)

	go sum(arr[:2], ch)
	go sum(arr[2:4], ch)
	go sum(arr[4:], ch)

	// x, y := <-ch, <-ch
	x, y, z := <-ch, <-ch, <-ch

	fmt.Printf("%d + %d + %d = %d\n", x, y, z, x+y+z)
}
